﻿using System;
using System.Linq;

namespace ProjetoComperio.Framework.Web.Logging
{
    public class Logger
    {
        /// <summary>
        /// This method saves an ExceptionLogging entity
        /// </summary>
        /// <param name="exceptionLogging"></param>
        public static void StoreException(ExceptionLogging exceptionLogging)
        {
            LoggingEntities entities = new LoggingEntities();
            entities.AddToExceptionLogging(exceptionLogging);
            entities.SaveChanges();
        }

        /// <summary>
        /// this method returns all exception logging
        /// </summary>
        /// <returns></returns>
        public static IQueryable<ExceptionLogging> RetrieveExceptions()
        {
            LoggingEntities entities = new LoggingEntities();
            return entities.ExceptionLogging;
        }
        /// <summary>
        /// This method returns an exception by its id
        /// </summary>
        /// <param name="exceptionLoggingID"></param>
        /// <returns></returns>
        public static ExceptionLogging RetrieveException(Int32 exceptionLoggingID)
        {
            return Logger.RetrieveExceptions().Where(exc => exc.ExceptionLoggingID == exceptionLoggingID).FirstOrDefault();
        }
    }
}
